// import { DECREMENT, INCREMENT } from '../const/counter.const'

// const initialState = {
//   count: 0
// }

// const counter = (state = initialState, action) => {
//   switch(action.type) {
//     case INCREMENT: 
//       return { 
//         ...state,
//         count: state.count + action.payload
//       }
//     case DECREMENT:
//       return {
//         ...state,
//         count: state.count - action.payload 
//       }
//     default: 
//       return state
//   }
// }

// export default counter

import { handleActions } from 'redux-actions'
import { increment, decrement } from '../actions/counter.action'

const initialState = { count :0 }
const handleIncrement = (state,action) => ({ count: state.count + action.payload})
const handleDecrement = (state) => ({ count: state.count - 1})

const counterReducer = handleActions({
  [increment]: handleIncrement,
  [decrement]: handleDecrement
}, initialState)

export default counterReducer